home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13526 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: nnrp.info.ucla.edu!jmartin
  2. From: jmartin@cs.ucla.edu (Jay Martin)
  3. Newsgroups: comp.lang.eiffel,comp.lang.c,comp.lang.c++,comp.object,comp.software-eng
  4. Subject: Re: Portability of code & skills (Beware of "C" Hackers etc)
  5. Date: 26 Mar 1996 06:01:11 GMT
  6. Organization: University of California, Los Angeles
  7. Message-ID: <4j8177$18ma@saba.info.ucla.edu>
  8. References: <31494D29.4D4B@dmu.ac.uk> <DoG3HE.48E@assip.csasyd.oz>     <31517E6F.5930@dmu.ac.uk> <DooBwC.8C0@world.std.com> <65O34-3-3RB@herold.franken.de>
  9. NNTP-Posting-Host: may.cs.ucla.edu
  10. X-Newsreader: NN version 6.5.0.b3.0 #9 (NOV)
  11.  
  12. jhd@herold.franken.de (Joachim Durchholz) writes:
  13.  
  14. >tej@world.std.com wrote 22.03.96 on Re: Portability of code & skills (Beware of "C" Hackers etc):
  15.  
  16. >> I don't remember enough Pascal to know what you mean.  I know you could
  17. >> define a function inside a function, making Pascal block-structured.
  18. >> C can't do that, but of course you can pass functions as arguments of
  19. >> functions.
  20.  
  21. >The power of this mechanism is that the local function can access local  
  22. >variables of its surrounding function. E.g. in a list processing  
  23. >environment you could write
  24.  
  25. >  function CountThem (l: List): integer;
  26. >  var Count: integer
  27. >    procedure CountOne (e: ListElement);
  28. >    begin
  29. >      if <some condition on e fulfilled> then begin
  30. >        Count := Count + 1;
  31. >      end;
  32. >    end;
  33. >  begin
  34. >    ApplyOnList (l, CountOne); (* !!!! *)
  35. >    CountThem := Count
  36. >  end;
  37.  
  38.  
  39. This is what I call side-effects on a global variable (or variable of
  40. a larger scope).  Its not what I call good programming practice.  In
  41. fact, I see nested procedures as implemented in algol block languages
  42. (automatic importation of variables from larger scopes) as another
  43. stupid idea of CS.  
  44.  
  45. Jay
  46.  
  47.  
  48.  
  49.  
  50.  
  51.